package com.huluobo.report

import com.huluobo.lib_base.BaseViewModel
import com.huluobo.lib_base.Res
import com.huluobo.lib_base.UIIntent
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

/**
 *  Created by LC on 2025/4/26.
 */
@HiltViewModel
class ReportViewModel @Inject constructor(private val reportRepo: ReportRepo) : BaseViewModel<ReportIntent>() {
    override fun handleIntent(it: UIIntent) {
        when (it) {
            is ReportIntent.GetAllReport -> {
                httpRequest(reportRepo.getReports() as Flow<Res<Any>>)
            }

            is ReportIntent.CommitReport -> {
                httpRequest(reportRepo.commitReport(it.map))
            }
        }
    }
}